﻿@{
    ViewBag.Title = "HistoricalPatientInfo";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section scripts{
    <script type="text/javascript">
    //页面动态改动
    $(window).resize(function () {
        $.setGridWithSearchBar("#TableForm", "#SearchBar", "#grid");
    });
    $(document).ready(function () {
        DisableBackspace();
        $('#start').datetimebox('setValue', '@ViewData["StartTime"]');
        $('#end').datetimebox('setValue', '@ViewData["EndTime"]');
        $('#CallPhone').textbox('setValue','@ViewData["CallPhone"]');
        $('#PatientName').textbox('setValue', '@ViewData["PatientName"]');
        bindGrid();
    })

    function bindGrid() {
        $('#grid').datagrid({
            width: 'auto',
            height: 'auto',
            fitColumns: true,
            striped: true,
            singleSelect: true,
            url: '@Url.Content("~/PR/HistoricalPatient/DataLoad")',
                loadMsg: '数据加载中请稍后……',
                pagination: true,//启用分页
                rownumbers: true,//显示页码
                pageSize: 15,//设置 页容量
                pageList: [10, 15, 20],//设置 页容量下拉框
                queryParams: {
                    StartTime: $('#start').datetimebox('getValue'),
                    EndTime: $('#end').datetimebox('getValue'),
                    CallPhone: $('#CallPhone').textbox('getValue'),
                    PatientName: $('#PatientName').textbox('getValue'),
                },
                columns: [[
                   { title: '病例填写时间', field: 'MedicalRecordGenerationTime', width: '20%', align: "center", sortable: false, formatter: $.formatTime },
                   { title: '事件类型', field: 'PatientVersion', width: '20%', align: "center", sortable: false, },
                   { title: '患者姓名', field: 'Name', width: '20%', align: "center", sortable: false },
                   { title: '联系电话', field: 'ContactTelephone', width: '20%', align: "center", sortable: false },
                   {
                       title: '操作', field: 'opt', width: '19%', align: "center", sortable: false,
                       formatter: function (value, row, index) {
                           var btn = '<a class="detail" onclick="ShowDetail(\'' + row.TaskCode + '\',\'' + row.PatientOrder + '\',\'' + row.PatientVersion + '\',\'' + row.SubmitLogo + '\')"  href="javascript:void(0)">详情</a>';
                           return btn;
                       }
                   },
                ]],
                onBeforeLoad:function(param){
                    if (param.CallPhone == "" && param.PatientName == "") {
                        $.messager.alert('提示', '无数据！', 'info');//title, msg, icon, fn
                        return false;
                    } else {
                        return true;
                    }
                },
                onLoadSuccess: function (data) {
                    if (data.total == 0) {
                        $.messager.alert('提示', '无数据！', 'info');
                    }
                    $('.detail').linkbutton({ text: '详情', plain: true, iconCls: 'icon-print' });
                    $('#grid').datagrid('fixRowHeight');//解决行号与行错位问题
                },
            })
            $.setGridWithSearchBar("#TableForm", "#SearchBar", "#grid");

        }

        function reSearch() {
            $('#grid').datagrid({
                pageNumber: 1,//点击查询返回第一页
                queryParams: {
                    StartTime: $('#start').datetimebox('getValue'),
                    EndTime: $('#end').datetimebox('getValue'),
                    CallPhone: $('#CallPhone').textbox('getValue'),
                    PatientName: $('#PatientName').textbox('getValue'),
                }
            })
        }

        function ShowDetail(TaskCode, PatientOrder, AlarmType, SubmitLogo) {
            var url = '@Url.Content("~/PR/HistoricalPatient/HistoricalPatientPrint/?TaskCode=")' + encodeURIComponent(TaskCode) + '&PatientOrder=' + PatientOrder + '&AlarmeventType=' + AlarmType + '&SubmitLogo=' + SubmitLogo;//传编码
            window.open(url);
        }
    </script>
}


<div id="TableForm" class="easyui-layout" style="width:auto; height: auto; margin-left: auto; margin-right: auto">
    <div data-options="region:'center',title:'',iconCls:'icon-custom-Entry'">
        <div id="SearchBar" data-options="region:'center'" style="overflow: hidden; padding: 10px">
            <table style="width:99%" cellpadding="0" cellspacing="5" border="0">
                <tr>
                    <td align="right" valign="middle" width="9%">日期：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="start" class="easyui-datetimebox" style="width:150px" data-options="editable:false" />
                    </td>
                    <td align="right" valign="middle" width="9%">至：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="end" class="easyui-datetimebox" style="width:150px" data-options="editable:false" />
                    </td>
                    <td align="right" valign="middle" width="9%">呼救电话：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="CallPhone" class="easyui-textbox" style="width:150px" readonly="readonly" />
                    </td>
                    <td align="right" valign="middle" width="9%">姓名：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="PatientName" class="easyui-textbox" style="width:150px" readonly="readonly" />
                    </td>
                    <td align="center" valign="middle" width="11%">
                        <a href="javascript:void(0)" id="btnsearch" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="reSearch()">查询</a>
                    </td>
                </tr>

            </table>
        </div>
        <div data-options="region:'center'" style="background: #fafafa; overflow: hidden">
            <table id="grid"></table>
        </div>
    </div>
</div>

